package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.AddressListBeen;
import cn.xfdzx.android.apps.shop.bean.VideoAvatarListBeen;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;

/**
 * Creator: zf.
 * Date: 2020/7/10.
 * Description:视频头像列表适配器.
 */
public class VideoHeadListMoreAdapter extends BaseQuickAdapter<VideoAvatarListBeen, BaseViewHolder>  {
    private OnItemOnClickListener onItemOnClickListener;
    private List<VideoAvatarListBeen> mList;
    public VideoHeadListMoreAdapter(Context mContext, @Nullable List<VideoAvatarListBeen> data) {
        super(R.layout.item_livemorehead, data);
        this.mContext = mContext;
    }

    @Override
    public void setData(int index, @NonNull VideoAvatarListBeen data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final VideoAvatarListBeen date) {
        TextView tv_index = viewHolder.getView(R.id.tv_index);
        viewHolder.setText(R.id.tv_nickname,date.getNickName());
        ImageView imageView = viewHolder.getView(R.id.img_head);
        ImageGlideUtil.loadAvatar(mContext,imageView,date.getHeadUrl());
        tv_index.setText(viewHolder.getLayoutPosition()+1+"");
        if (viewHolder.getLayoutPosition() == 0){
            tv_index.setBackgroundResource(R.drawable.circle_fe2451slide);
        }else if (viewHolder.getLayoutPosition() == 1){
            tv_index.setBackgroundResource(R.drawable.circle_fea922slide);
        }else if (viewHolder.getLayoutPosition() == 2){
            tv_index.setBackgroundResource(R.drawable.circle_b7bedaslide);
        }else {
            tv_index.setBackgroundResource(R.drawable.circle_d7d5d5slide);
        }

    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<VideoAvatarListBeen> list){
        this.mList = list;
        super.replaceData(list);
    }

    public void setItemOnClickListener(OnItemOnClickListener listener){
        this.onItemOnClickListener = listener;
    }

    public interface OnItemOnClickListener {
        void onItemClick(int address_id, int type, AddressListBeen.DataBean date);
    }

}
